package comWorld.action.blog;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import comWorld.blog.BlogInfo;
import comWorld.blog.BlogInfoManage;
import comWorld.blog.BlogInfos;
import comWorld.user.UserInfo;

/**
 * Servlet implementation class DeleteDraft
 */
@WebServlet("/action/blog/deleteDraft")
public class DeleteDraft extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteDraft() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int draftId = Integer.valueOf(request.getParameter("draftId"));
		BlogInfos draftInfos = (BlogInfos) request.getSession().getAttribute("draftInfos");
		BlogInfoManage.deleteBlog(draftInfos.getUserId(), draftId, getServletContext());
		draftInfos.remove(draftId);
	}

}
